import { newsListPage,newsCreate } from "@/api/news"

const news = {
  state: {
    data:{}
  },

  mutations: {
    newsList:(state,data)=>{
      state.data=data;
    },
    newsCreate:(state,data)=>{
        state.data=data;
      }
  },

  actions: {
    // 无页码约束的所有用户数据
    //es6
    newsList({commit},playload) {
      return new Promise((resolve, reject) => {
        newsListPage(playload).then(response => {
        //   console.log(response);
          commit("newsList",response);
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    newsCreate({commit},playload) {
        return new Promise((resolve, reject) => {
            newsCreate(playload).then(response => {
            console.log(response);
            commit("newsCreate",response);
            resolve(response)
          }).catch(error => {
            reject(error)
          })
        })
      }

  }
}

export default news;
